##stringtype Oberon
##shortstrings
<* STANDARD- *> <* MAIN- *> <* INITIALISE- *>

MODULE %o3;
(****************************************************************

   This file was created automatically by `%fv'
   Do NOT edit by hand!
   Oberon-A source description C 1994 by Albert Weinert
   Using with Oberon-A Interfaces for AmigaOS Release 3.1
   Modified for Oberon-A 1.5 by Frank Copeland

   Application: %b
   Language   : %l
   Version    : %v
   Description: %f0

****************************************************************)

IMPORT
  lo := Locale, e := Exec, u := Utility, y := SYSTEM;

CONST
  builtinlanguage = %l;
  version = %v;

CONST
  %i* = %d;

TYPE
  AppString = RECORD;
     id  : LONGINT;
     str : e.LSTRPTR;
  END;
  AppStringArray = ARRAY %n OF AppString;

VAR
  AppStrings : AppStringArray;
  catalog : lo.CatalogPtr;

  PROCEDURE SetStrings;
    BEGIN
      AppStrings[%e].id := %i; AppStrings[%e].str := y.ADR( %s );
    END SetStrings;

  PROCEDURE CloseCatalog*();
    BEGIN
      IF catalog # NIL THEN lo.CloseCatalog (catalog); catalog:=NIL END;
   END CloseCatalog;

  PROCEDURE OpenCatalog*(loc:lo.LocalePtr; language:ARRAY OF CHAR);
    VAR Tag : ARRAY 4 OF u.TagItem;
    BEGIN
      CloseCatalog();
      IF (catalog = NIL) & (lo.base # NIL) THEN
        Tag[0].tag := lo.builtInLanguage; Tag[0].data := y.ADR( builtinlanguage );
        Tag[1].tag := u.ignore;           Tag[1].data := y.ADR( language );
        Tag[2].tag := lo.version;         Tag[2].data := version;
        Tag[3].tag := u.done;

        IF language # "" THEN
          Tag[1].tag:= lo.language;
        END;
        catalog := lo.OpenCatalogA (loc, "%b.catalog", Tag);
      END;
    END OpenCatalog;

  PROCEDURE GetString* (num: LONGINT): e.LSTRPTR;
    VAR
      i: LONGINT;
      default: e.LSTRPTR;
    BEGIN
      i := 0; WHILE (i < %n) & (AppStrings[i].id # num) DO INC (i) END;

      IF i # %n THEN
        default := AppStrings[i].str;
      ELSE
        default := NIL;
      END;

      IF catalog # NIL THEN
        RETURN lo.GetCatalogStr (catalog, num, default^);
      ELSE
        RETURN default;
      END;
    END GetString;

BEGIN
  catalog := NIL;
  SetStrings;
END %o3.

